package servlets;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import domain.IDAOContactGroup;

public class PrepareContactCreationAction extends Action {
	public ActionForward execute(final ActionMapping pMapping,
			ActionForm pForm, final HttpServletRequest request,
			final HttpServletResponse response) {
			ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServlet().getServletContext());
			IDAOContactGroup dao = (IDAOContactGroup) context.getBean("daocontactgroup");
			request.setAttribute("groups", dao.getContactGroups().toArray());
			return pMapping.findForward("createContact");
	}
}
